/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - core/containers
// Copyright( c) 2014.  All Rights Reserved
//
// File:		AEStringMap.inl
// Author:		Gianluca Belardelli
// Date:		21/10/2014
//
/////////////////////////////////////////////////////////////////////////
#ifndef _AESTRINGMAP_INL_
#define _AESTRINGMAP_INL_

template <typename V, typename AEAllocator>
AE_FORCEINLINE AEStringMap<V,AEAllocator>::AEStringMap( void )
{
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE void AEStringMap<V,AEAllocator>::Insert( const char *lpKey, V tVal )
{
	m_mapMap.Insert( AEUINT32( lpKey ), AEUINT32( tVal ) );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE typename AEStringMap<V,AEAllocator>::AEIterator AEStringMap<V,AEAllocator>::FindKey( const char *lpKey ) const
{
	return m_mapMap.FindKey( AEUINT32( lpKey ) );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE typename AEStringMap<V,AEAllocator>::AEIterator AEStringMap<V,AEAllocator>::FindOrInsertKey( const char *lpKey, V tVal )
{
	return m_mapMap.FindOrInsertKey( AEUINT32( lpKey ), AEUINT32( tVal ) );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE AEBOOL32 AEStringMap<V,AEAllocator>::HasKey( const char *lpKey ) const
{
	return m_mapMap.HasKey( AEUINT32( lpKey ) );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE V AEStringMap<V,AEAllocator>::GetOrInsert( const char *lpKey, V tIfNotFound )
{
	return (V)m_mapMap.GetOrInsert( AEUINT32( lpKey ), AEUINT32( tIfNotFound ) );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE V AEStringMap<V,AEAllocator>::GetWithDefault( const char *lpKey, V tDefault ) const
{
	return (V)m_mapMap.GetWithDefault( AEUINT32( lpKey ), AEUINT32( tDefault ) );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE AEUINT32 AEStringMap<V,AEAllocator>::Get( const char *lpKey, V *lpOut ) const
{
	AEUINT32 uiTmp;
	if( m_mapMap.Get( AEUINT32( lpKey ), &uiTmp ) == 1 )
	{
		*lpOut = V(uiTmp);
		return 1;
	}

	return 0;
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE void AEStringMap<V,AEAllocator>::Remove( AEIterator itIter )
{
	m_mapMap.Remove( itIter );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE AEUINT32 AEStringMap<V,AEAllocator>::Remove( const char *lpKey )
{
	return m_mapMap.Remove( AEUINT32( lpKey ) );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE AEINT32 AEStringMap<V,AEAllocator>::GetSize( void ) const
{
	return m_mapMap.GetSize();
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE AEBOOL32 AEStringMap<V,AEAllocator>::IsOk( void ) const
{
	return m_mapMap.IsOk();
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE typename AEStringMap<V,AEAllocator>::AEIterator AEStringMap<V,AEAllocator>::GetIterator( void ) const
{
	return m_mapMap.GetIterator();
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE const char *AEStringMap<V,AEAllocator>::GetKey( AEIterator itIter ) const
{
	return reinterpret_cast<const char*>( m_mapMap.GetKey( itIter ) );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE V AEStringMap<V,AEAllocator>::GetValue( AEIterator itIter ) const
{
	return (V)m_mapMap.GetValue( itIter );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE void AEStringMap<V,AEAllocator>::SetValue( AEIterator itIter, V tValue )
{
	m_mapMap.SetValue( itIter, AEUINT32( tValue ) );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE typename AEStringMap<V,AEAllocator>::AEIterator AEStringMap<V,AEAllocator>::GetNext( AEIterator itIter ) const
{
	return m_mapMap.GetNext( itIter );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE AEBOOL32 AEStringMap<V,AEAllocator>::IsValid( AEIterator itIter ) const
{
	return m_mapMap.IsValid( itIter );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE void AEStringMap<V,AEAllocator>::Clear( void )
{
	m_mapMap.Clear();
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE void AEStringMap<V,AEAllocator>::Reset( void )
{
	AECachedHashMap<AEStringMapOperations, AEAllocator> newMap;
	m_mapMap.Swap( newMap );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE void AEStringMap<V,AEAllocator>::Swap( AEStringMap &refOther )
{
	m_mapMap.Swap( refOther.m_mapMap );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE void AEStringMap<V,AEAllocator>::Merge( const AEStringMap &refOther )
{
	m_mapMap.Merge( refOther.m_mapMap );
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE AEINT32 AEStringMap<V,AEAllocator>::GetCapacity( void ) const
{
	return m_mapMap.GetCapacity();
}

template <typename V, typename AEAllocator>
AE_FORCEINLINE void AEStringMap<V,AEAllocator>::Reserve( AEINT32 nNumElements )
{
	m_mapMap.Reserve( nNumElements );
}

#endif // _AESTRINGMAP_INL_

